﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DotNet.Common.Command;
using ZLCMS.Commands.Sys.Commands.Order;
using ZLCMS.Business.Util;

namespace ZLCMS.Web.PayChannal.Weixinpay
{
    public partial class CheckPayStatus : ZLCMS.Web.Wap.Code.MemberPageBase
    {
        protected bool isPay { get; set; }
        protected void Page_Load(object sender, EventArgs e)
        {
            string pno = Request["pno"];

            using (NHibernate.ISession session = DotNet.Common.NHibernateUtil.SessionFactoryHelper.CreateSession())
            {
                pno = session.CreateSQLQuery("select payment_no from shop_order_info where payment_no=:pno and member_account=:acc")
                    .SetParameter("pno", pno)
                    .SetParameter("acc", CurrentMemberAccount)
                    .SetMaxResults(1)
                    .UniqueResult<string>();
            }

            if (!string.IsNullOrEmpty(pno))
            {

                SynchroPayStatusCommand synchroCmd = new WXPaySynchroPayStatusCommand();
                ICommandResult<SynchroPayStatusResult> synchroResult = synchroCmd.Execute(new SynchroPayStatusParameter() { PaymentNo = pno });

                isPay = !synchroResult.Error;
                //CMSKits.WriteLog("wxpay_synchro", synchroResult.ErrorMsg, "");
                //Response.Redirect("/Wap/Shop/OrderList.aspx");

            }
        }
    }
}